package com.atguigu.gulimall.juc.demo;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class CycleBarrierDemo {
    public static void main(String[] args) {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(60,()->{
            System.out.println("全体成员已经到齐开会");
        });
        for (int i = 0; i < 60; i++) {
            int finalI = i;
            new Thread(()->{
                System.out.println(finalI+"号同学到位");
                try {
                    cyclicBarrier.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            },String.valueOf(i)).start();
        }
        ThreadLocal local = new ThreadLocal();
    }
}
